home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3863
/
3863.xpi
/
chrome
/
imacros.jar
/
content
/
options.js
< prev
next >
Wrap
Text File
|
2010-01-25
|
11KB
|
5 lines
//*/
/*
(c) Copyright 2008 iOpus Software GmbH - http://www.iopus.com
*/
function getiMacrosPM(){var pm=null;try{pm=imns.Cc["@iopus.com/password-manager;1"];pm=pm.getService(imns.Ci.nsISupports);return pm.wrappedJSObject;}catch(e){Components.utils.reportError(e);throw "Can't instantiate Password Manager!";}};window.onload=function(){try{var delayval=im_Pref.getIntPref("delay");var elem=null;if(delayval<=100||isNaN(delayval)){elem=document.getElementById('delayfast');}else if(delayval<=1000){elem=document.getElementById('delaymedium');}else{elem=document.getElementById('delayslow');}var radiogrp=document.getElementById("replay-speed");radiogrp.selectedItem=elem;var effects={scroll:null,highlight:null,showjs:null};for(var x in effects){var chkbox=document.getElementById(x);effects[x]=im_Pref.getBoolPref(x);chkbox.checked=effects[x];}var maxwait=document.getElementById("maxwait");maxwait.value=im_Pref.getIntPref("maxwait");var pm=getiMacrosPM();var sec=document.getElementById("sec"+pm.encryptionType.toString());var pwdusage=document.getElementById("masterpwd-usage");pwdusage.selectedItem=sec;updatePasswordControls(pm.encryptionType);var sec2master=document.getElementById("sec2master");try{sec2master.value=pm.getMasterPwd();}catch(x){}var epath=document.getElementById('editpath');var ebtn=document.getElementById('editpathbtn');var chkeditor=document.getElementById('chkeditor');if(im_Pref.getBoolPref("externaleditor")){chkeditor.checked=true;epath.disabled=null;ebtn.disabled=null;}else{chkeditor.checked=false;epath.disabled=true;ebtn.disabled=true;}var x=im_Pref.getFilePref("externaleditorpath");epath.value=x?x.path:"";setPathValues();var store_check=document.getElementById("store-in-profile");if(im_Pref.getBoolPref("store-in-profile")){store_check.checked=true;disablePathsBoxes(true);}else{store_check.checked=false;disablePathsBoxes(null);}fillList();}catch(e){Components.utils.reportError(e);}};function getRequestWatcher(){var watcher=null;try{watcher=imns.Cc["@iopus.com/requestwatcher;1"];watcher=watcher.getService(imns.Ci.nsISupports);watcher=watcher.wrappedJSObject;return watcher;}catch(e){Components.utils.reportError(e);throw "Can't instantiate ReqeustWatcher!";}};function onSelectWhiteList(){var wlist=document.getElementById("white-list");var btn_remove=document.getElementById("remove-site");var btn_toggle=document.getElementById("toggle-site");btn_remove.disabled=null;btn_toggle.disabled=null;var item=wlist.selectedItem;if(!item)return;var state=item.lastChild.getAttribute("label");if(state=="allowed"){btn_toggle.label="Block";}else{btn_toggle.label="Allow";}};function onTextBoxKeypress(evt){const VK_ENTER=imns.Ci.nsIDOMKeyEvent.DOM_VK_ENTER;const VK_RETURN=imns.Ci.nsIDOMKeyEvent.DOM_VK_RETURN;if(evt.keyCode==VK_RETURN||evt.keyCode==VK_ENTER){addSite();evt.preventDefault();}};function onListKeydown(evt){const VK_DELETE=imns.Ci.nsIDOMKeyEvent.DOM_VK_DELETE;if(evt.keyCode==VK_DELETE){removeSites();evt.preventDefault();}};function onListDblClick(evt){if(evt.button==0)toggleSite();};function checkSiteSpelling(site){var arr=null;if(arr=site.match(/^(\w+):\/\/([\w.]+)\/(\S*)$/)){return arr[2];}else if(arr=site.match(/^([\w-]+(\.[\w-]+)+)\/?.*$/)){return arr[1];}else{alert("The value entered must be a valid URL or domain name (e.g. www.example.com)");return null;}};function fillList(sortorder){var wlist=document.getElementById("white-list");var watcher=getRequestWatcher();var sites=watcher.enumerateSites();if(!sortorder)sortorder="a";while(wlist.getRowCount())wlist.removeItemAt(0);var site=null;var arr=new Array();for(site in sites)arr.push(site);var ascending=function(x,y){return x.localeCompare(y);};var descending=function(x,y){return y.localeCompare(x);};if(sortorder=="a")arr.sort(ascending);else arr.sort(descending);for(var i=0;i<arr.length;i++){var li=document.createElement("listitem");var lc_site=document.createElement("listcell");lc_site.setAttribute("label",arr[i]);lc_site.setAttribute("tooltiptext","Double click on the item changes its status");var lc_status=document.createElement("listcell");lc_status.setAttribute("label",sites[arr[i]]?"allowed":"blocked");li.appendChild(lc_site);li.appendChild(lc_status);wlist.appendChild(li);}};function addSite(){var textbox=document.getElementById("add-site-textbox");var watcher=getRequestWatcher();var site=checkSiteSpelling(textbox.value);if(!site){textbox.focus();textbox.select();return;}watcher.addSite(site);textbox.value="";textbox.popupOpen=false;fillList();};function removeSites(){var wlist=document.getElementById("white-list");var watcher=getRequestWatcher();for(var i=0;i<wlist.selectedCount;i++){var li=wlist.getSelectedItem(i);var site=li.firstChild.getAttribute("label");watcher.removeSite(site);}fillList();};function toggleSite(){var wlist=document.getElementById("white-list");var watcher=getRequestWatcher();var btn_toggle=document.getElementById("toggle-site");var li=wlist.selectedItem;var site=li.firstChild.getAttribute("label");var status=li.lastChild.getAttribute("label");if(status=="allowed"){watcher.blockSite(site);li.lastChild.setAttribute("label","blocked");btn_toggle.label="Allow";}else{watcher.addSite(site);li.lastChild.setAttribute("label","allowed");btn_toggle.label="Block";}};function testPath(path){try{var x=im_FIO.openNode(path);}catch(e){window.alert("Can not recognize path syntax for '"+path+"'!");return false;}if(!x.exists()){window.alert("Path '"+path+"' does not exist!");return false;}return true;};function do_accept(){try{if(document.getElementById('delayfast').selected){im_Pref.setIntPref("delay",0);}else if(document.getElementById('delaymedium').selected){im_Pref.setIntPref("delay",1000);}else{im_Pref.setIntPref("delay",2000);}var effects={scroll:null,highlight:null,showjs:null};for(var x in effects){var chkbox=document.getElementById(x);effects[x]=chkbox.checked;im_Pref.setBoolPref(x,effects[x]);}var maxwait=document.getElementById("maxwait");if(/^\d+$/.test(maxwait.value))im_Pref.setIntPref("maxwait",__int(maxwait.value));var pm=getiMacrosPM();if(pm.encryptionType==pm.TYPE_STORED){var sec2master=document.getElementById("sec2master");if(!sec2master.value){alert("Master password can not be empty!");sec2master.focus();return;}pm.setMasterPwd(sec2master.value);}var chkeditor=document.getElementById('chkeditor');if(chkeditor.checked){im_Pref.setBoolPref("externaleditor",true);var epath=document.getElementById('editpath');if(!testPath(epath.value))return false;im_Pref.setFilePref("externaleditorpath",im_FIO.openNode(epath.value));}else{im_Pref.setBoolPref("externaleditor",false);}if(!im_Pref.getBoolPref("store-in-profile")){var savepath=document.getElementById("savepath");if(!testPath(savepath.value))return false;im_Pref.setFilePref("defsavepath",im_FIO.openNode(savepath.value));var logpath=document.getElementById("logpath");if(!testPath(logpath.value))return false;im_Pref.setFilePref("deflogpath",im_FIO.openNode(logpath.value));var datapath=document.getElementById("datapath");if(!testPath(datapath.value))return false;im_Pref.setFilePref("defdatapath",im_FIO.openNode(datapath.value));var downpath=document.getElementById("downpath");if(!testPath(downpath.value))return false;im_Pref.setFilePref("defdownpath",im_FIO.openNode(downpath.value));var wm=imns.Cc["@mozilla.org/appshell/window-mediator;1"].getService(imns.Ci.nsIWindowMediator);var enumerator=wm.getEnumerator("navigator:browser");while(enumerator.hasMoreElements()){var win=enumerator.getNext();if(win.sidebar&&win.sidebar.initMTree)win.sidebar.initMTree();}}window.close();}catch(e){Components.utils.reportError(e);}};function browseForFile(prefname,elemname){try{var fp=imns.Cc["@mozilla.org/filepicker;1"].createInstance(imns.Ci.nsIFilePicker);fp.init(window," ",imns.Ci.nsIFilePicker.modeOpen);fp.appendFilters(imns.Ci.nsIFilePicker.filterApps);fp.appendFilters(imns.Ci.nsIFilePicker.filterAll);fp.filterIndex=0;var rv=fp.show();if(rv==imns.Ci.nsIFilePicker.returnOK){var file=fp.file.path.toString();im_Pref.setFilePref(prefname,im_FIO.openNode(file));document.getElementById(elemname).value=file;}}catch(e){Components.utils.reportError(e);}};function browseForFolder(prefname,elemname){try{var fp=imns.Cc["@mozilla.org/filepicker;1"].createInstance(imns.Ci.nsIFilePicker);fp.init(window," ",imns.Ci.nsIFilePicker.modeGetFolder);var rv=fp.show();if(rv==imns.Ci.nsIFilePicker.returnOK){var file=fp.file.path.toString();im_Pref.setFilePref(prefname,im_FIO.openNode(file));document.getElementById(elemname).value=file;}}catch(e){Components.utils.reportError(e);}};function updatePasswordControls(val){try{var pm=getiMacrosPM();if(!/^[123]$/.test(val.toString()))val=1;pm.encryptionType=val;var sec2master=document.getElementById("sec2master");var tmp_master=document.getElementById('tmp-master');if(val==1){sec2master.disabled=true;tmp_master.disabled=true;}else if(val==2){sec2master.disabled=null;tmp_master.disabled=true;sec2master.focus();}else if(val==3){sec2master.disabled=true;tmp_master.disabled=null;tmp_master.focus();}}catch(e){Components.utils.reportError(e);}};function updateEditorField(){try{var path=document.getElementById('editpath');var btn=document.getElementById('editpathbtn');var chkbox=document.getElementById('chkeditor');if(!chkbox.checked){path.disabled=true;btn.disabled=true;}else{path.disabled=null;btn.disabled=null;path.focus();}}catch(e){Components.utils.reportError(e);}};function enterTempPassword(){var pm=getiMacrosPM(),param={password:pm.getSessionPwd()};window.openDialog('chrome://imacros/content/keydlg1.xul','','modal,centerscreen',param);pm.setSessionPwd(param.password);};function setPathValues(){var paths=["savepath","logpath","datapath","downpath"];for(var i=0;i<paths.length;i++){var value=im_Pref.getFilePref("def"+paths[i]).path;var box=document.getElementById(paths[i]);box.value=value;}};function disablePathsBoxes(val){var paths=["savepath","logpath","datapath","downpath"];for(var i=0;i<paths.length;i++){var p=document.getElementById(paths[i]);var b=document.getElementById("browse-"+paths[i]);p.disabled=val?val:null;b.disabled=val?val:null;}};function storeInProfile(){var store_check=document.getElementById('store-in-profile');im_Pref.setBoolPref("store-in-profile",store_check.checked);disablePathsBoxes(store_check.checked);setPathValues();if(!store_check.checked){var paths=["savepath","logpath","datapath","downpath"];for(var i=0;i<paths.length;i++){var p=document.getElementById(paths[i]);if(!testPath(p.value))return;}}var wm=imns.Cc["@mozilla.org/appshell/window-mediator;1"].getService(imns.Ci.nsIWindowMediator);var enumerator=wm.getEnumerator("navigator:browser");while(enumerator.hasMoreElements()){var win=enumerator.getNext();if(win.sidebar&&win.sidebar.initMTree)win.sidebar.initMTree();}};function lookAt(folder){}